/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2018-01-6 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.admin.controller.sys;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.itttq.gshop.admin.controller.GenericController;
import com.itttq.gshop.domain.to.PageParamTo;
import com.itttq.gshop.domain.to.ResultPageTo;
import com.itttq.gshop.domain.po.SysFloorImgPo;
import com.itttq.gshop.generic.connector.ISysFloorImgConnector;

@RestController
@RequestMapping("sys/floorImg")
public class SysFloorImgController extends GenericController {
	private static final long serialVersionUID = 638162097212717172L;
	@Autowired
	private ISysFloorImgConnector sysFloorImgConnector;
	
	/**
	 * 根据条件查询SysFloorImgPo对象，并分页
	 * 
	 * @param sysFloorImg
	 * @param request
	 * @return
	 * @Author 迷蝶
	 * @return ModelAndView
	 */
	@RequestMapping("floorImgs.html")
	public ModelAndView getSysFloorImgs(SysFloorImgPo sysFloorImg, HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/sys/floorImgs");
		PageParamTo ppt = null == request ? new PageParamTo() : getPageParam(request);
		sysFloorImg.setStart(ppt.getStart());
		sysFloorImg.setSize(ppt.getSize());
		ResultPageTo<SysFloorImgPo> rpt = sysFloorImgConnector.getSysFloorImgs(sysFloorImg);
		this.getPageMv("floorImgs", mv, rpt);
		mv.addObject("floorImg", sysFloorImg);
		return mv;
	}

	
	/**
	 * 跳转到新增页面
	 * @return
	 */
	@RequestMapping("add.html")
	public ModelAndView addSysFloorImg() {
		ModelAndView mv = new ModelAndView("/sys/floorImgAdd");
		
		return mv;
	}
	/**
	 * 跳转到查看页面
	 * @param id
	 * @return
	 */
	@RequestMapping("view/{id}.html")
	public ModelAndView viewSysFloorImg(@PathVariable("id") Integer id) {
		ModelAndView mv = addSysFloorImg();
		if(id != null) {
			mv.addObject("floorImg", sysFloorImgConnector.getSysFloorImg(id));
		}
		mv.addObject("op", "view");
		return mv;
	}
	/**
	 * 跳转到编辑页面
	 * @param id
	 * @return
	 */
	@RequestMapping("edit/{id}.html")
	public ModelAndView editSysFloorImg(@PathVariable("id") Integer id) {
		ModelAndView mv = viewSysFloorImg(id);
		mv.addObject("op", "edit");
		return mv;
	}
	
	/**
	 * 保存SysFloorImgPo对象，无ID则新增，有ID则更新
	 * 
	 * @param sysFloorImg
	 * @return
	 * @Author 迷蝶
	 * @return ModelAndView
	 */
	@RequestMapping("save.html")
	public ModelAndView saveSysFloorImg(SysFloorImgPo sysFloorImg) {
		sysFloorImgConnector.saveSysFloorImg(sysFloorImg);
		return getSysFloorImgs(new SysFloorImgPo(), null);
	}

	/**
	 * 根据ID删除SysFloorImgPo对象
	 * 
	 * @param id
	 * @return
	 * @Author 迷蝶
	 * @return ModelAndView
	 */
	@RequestMapping("del/{id}.html")
	@ResponseBody
	public ModelAndView delSysFloorImg(@PathVariable("id") Integer id) {
		if(id != null) {
			sysFloorImgConnector.delSysFloorImg(id);
		}
		return getSysFloorImgs(new SysFloorImgPo(), null);
	}
}